#include<bits/stdc++.h>
using namespace std;
const int ND=20;
int n,m,d[ND],ok[ND][2][2],f[ND][2][2];
int F(int p,bool limit,bool pre1){
    if(p==0) return 1;
    if(ok[p][limit][pre1]) return f[p][limit][pre1];
    ok[p][limit][pre1]=1;
    f[p][limit][pre1]=0;
    for(int i=0;i<=(limit?d[p]:9);i++){
        if(i==4) continue;
        if(pre1&&i==3) continue;
        f[p][limit][pre1]+=F(p-1,limit&&i==d[p],i==1);
    }
    return f[p][limit][pre1];
}
int solve(int x){
    memset(ok,0,sizeof(ok));
    memset(f,0,sizeof(f));
    int nD=0;
    do{
        d[++nD]=x%10;
        x/=10;
    }while(x);
    return F(nD,1,0);
}
int main(){
    //freopen("thirteen.in","r",stdin);
    //freopen("thirteen.out","w",stdout);
    cin>>n>>m;
    cout<<solve(m)-solve(n-1)<<endl;
    return 0;
}